﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using YesBlog.Application.User;
using YesBlog.Application.User.Dto;
using YesBlog.Framework.Controllers;

namespace YesBlog.Web.Areas.Admin.Controllers
{
    public class UserController : BaseController
    {

        private IUserService _userService;

        public UserController(IUserService userService)
        {
            _userService = userService;
        }


        public IActionResult Index()
        {
            return View();
        }

        [AllowAnonymous, HttpGet]
        public IActionResult Login()
        {
            return View();
        }

        [AllowAnonymous, HttpPost]
        public IActionResult Login(UserLoginDto dto)
        {
            return Json(_userService.Login(dto));
        }

        [HttpGet]
        public IActionResult Logout()
        {
            _userService.Logout();
            return RedirectToAction("Login");
        }

        [HttpGet]
        public IActionResult ChangePasword()
        {
            return View();
        }




    }
}